{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c70c8abc-e701-4ccc-a445-012c62b7215e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-07-06T11:53:17.817042Z",
     "iopub.status.busy": "2022-07-06T11:53:17.816728Z",
     "iopub.status.idle": "2022-07-06T11:53:21.685393Z",
     "shell.execute_reply": "2022-07-06T11:53:21.684510Z",
     "shell.execute_reply.started": "2022-07-06T11:53:17.816950Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ClientContext(dashboard_url='127.0.0.1:8265', python_version='3.7.10', ray_version='1.13.0', ray_commit='e4ce38d001dbbe09cd21c497fedd03d692b2be3e', protocol_version='2022-03-16', _num_clients=5, _context_to_restore=<ray.util.client._ClientContext object at 0x7f8548ec14d0>)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import ray\n",
    "\n",
    "ray.shutdown()\n",
    "ray.init(address=\"ray://localhost:10001\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "63ebdbe3-17d4-4d20-90be-cf46fb6cb98e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-07-06T11:53:21.686585Z",
     "iopub.status.busy": "2022-07-06T11:53:21.686405Z",
     "iopub.status.idle": "2022-07-06T11:53:25.223802Z",
     "shell.execute_reply": "2022-07-06T11:53:25.223237Z",
     "shell.execute_reply.started": "2022-07-06T11:53:21.686564Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-07-06 11:53:21,949\tWARNING read_api.py:256 -- The number of blocks in this dataset (1) limits its parallelism to 1 concurrent tasks. This is much less than the number of available CPU slots in the cluster. Use `.repartition(n)` to increase the number of dataset blocks.\n",
      "Caught schedule exception\n",
      "2022-07-06 11:53:21,973\tINFO common.py:220 -- Exception from actor creation is ignored in destructor. To receive this exception in application code, call a method on the actor reference before its destructor is run.\n",
      "Read: 100%|██████████| 1/1 [00:01<00:00,  1.23s/it]\n",
      "Sort Sample: 100%|██████████| 1/1 [00:00<00:00, 72.85it/s]\n",
      "Shuffle Map: 100%|██████████| 1/1 [00:00<00:00,  4.84it/s]\n",
      "Shuffle Reduce: 100%|██████████| 1/1 [00:01<00:00,  1.06s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'sentiment': -1, 'count()': 1845}\n",
      "{'sentiment': 0, 'count()': 1846}\n",
      "{'sentiment': 1, 'count()': 1846}\n",
      "CPU times: user 104 ms, sys: 29.6 ms, total: 133 ms\n",
      "Wall time: 3.53 s\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.33)\u001b[0m Spilled 10657 MiB, 23 objects, write throughput 205 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.111)\u001b[0m Spilled 13488 MiB, 289 objects, write throughput 283 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.33)\u001b[0m Spilled 15934 MiB, 24 objects, write throughput 252 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.111)\u001b[0m Spilled 16739 MiB, 290 objects, write throughput 323 MiB/s.\n",
      "\u001b[2m\u001b[36m(raylet, ip=172.31.26.33)\u001b[0m Spilled 16766 MiB, 161 objects, write throughput 262 MiB/s.\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "\n",
    "df = ray.data.read_csv(paths=\"s3://dsoaws/ray/datasets/data/train/part-algo-1-womens_clothing_ecommerce_reviews.csv\")\n",
    "\n",
    "df.groupby(\"sentiment\").count().show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8efafc67-bd51-4907-966f-01fb029408d0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
